﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MyAdmin/QuanLy.master" AutoEventWireup="true"
    CodeFile="HoaDon_AM (bỏ).aspx.cs" Inherits="MyAdmin_HoaDon_AM" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <fieldset>
        <table border="0" cellspacing="0" cellpadding="0" width="50%">
            <tr>
                <td>
                    Tên ĐN Khách Hàng
                </td>
                <td>
                    <asp:TextBox ID="txtTenDNKH_TK" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Từ Ngày ĐH
                </td>
                <td>
                    <asp:Calendar ID="calTuNgayDH_TK" runat="server"></asp:Calendar>
                </td>
            </tr>
            <tr>
                <td>
                    Đến Ngày ĐH
                </td>
                <td>
                    <asp:Calendar ID="calDenNgayDH_TK" runat="server"></asp:Calendar>
                </td>
            </tr>
            <tr>
                <td>
                    Địa Chỉ GH
                </td>
                <td>
                    <asp:TextBox ID="txt_DiaChiGH" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Button ID="btnTimKiem_NCCGH" runat="server" Text="Tìm Kiếm" OnClick="btnTimKiem_NCCGH_Click" />
                </td>
            </tr>
        </table>
        <asp:Label ID="lblTBKhongTimThay" ForeColor="White" runat="server" Visible="false"
            Text="Không tìm thấy sản phẩm nào!"></asp:Label>
        <legend align="center"><b>Hóa Đơn</b></legend>
        <asp:GridView ID="gvDSNCC_GiangHang" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None"
            BorderWidth="1px" CellPadding="3" GridLines="Vertical" OnPageIndexChanging="gvDSNCC_GiangHang_PageIndexChanging"
            OnSelectedIndexChanged="gvDSNCC_GiangHang_SelectedIndexChanged">
            <AlternatingRowStyle BackColor="#DCDCDC" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" SelectText="Chọn" />
                <asp:BoundField DataField="ID" HeaderText="ID" />
                <asp:BoundField DataField="TenDNKH" HeaderText="Khách Hàng" />
                <asp:BoundField DataField="TenTT" HeaderText="Trạng Thái" />
                <asp:BoundField DataField="CreatedDate" HeaderText="Ngày Đặt Hàng" />
                <asp:BoundField DataField="NgayHangDuocGiao" HeaderText="Ngày Đã Giao" 
                    Visible="False" />
                <asp:CheckBoxField DataField="DaXoa" HeaderText="Đã Xóa" />
                <asp:BoundField DataField="TenNVC" HeaderText="Nhà Vận Chuyển" />
                <asp:BoundField DataField="DiaChiGH" HeaderText="Địa Chỉ GH" />
                <asp:BoundField DataField="TongTien" HeaderText="Tổng Tiền" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="checkXoa" runat="server" AutoPostBack="True" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
            <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#0000A9" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#000065" />
        </asp:GridView>
        <asp:Button ID="XoaNhieuBUTTON" runat="server" Text="Xóa Đã Chọn" OnClick="XoaNhieuBUTTON_Click" />
        <asp:Label ID="lblThongBaoGridView" runat="server" ForeColor="White" Text="Label"></asp:Label>
        <br />
        <asp:DetailsView ID="dtChiTietGiangHang" runat="server" Height="50px" Width="40%"
            AutoGenerateRows="False" BackColor="White" DataKeyNames="ID" DataSourceID="LQDSHoaDon_AM"
            HeaderText="Chi Tiết Hóa Đơn" OnItemInserted="dtChiTietGiangHang_ItemInserted"
            OnItemUpdated="dtChiTietGiangHang_ItemUpdated" 
            oniteminserting="dtChiTietGiangHang_ItemInserting" BorderColor="#999999" 
            BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
            <AlternatingRowStyle BackColor="#DCDCDC" />
            <EditRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
            <Fields>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                    SortExpression="ID" />
                <asp:BoundField DataField="CreatedDate" HeaderText="CreatedDate" SortExpression="CreatedDate"
                    Visible="False" />
                <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" SortExpression="CustomerID"
                    Visible="False" />
                <asp:TemplateField HeaderText="Khách Hàng">
                    <ItemTemplate>
                        <asp:Label ID="customerID" runat="Server" Text='<%# Eval("TenDNKH") %>' />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:Label ID="lblCustomerID_ForEdit" Text='<%# Bind("CustomerID") %>' Visible="false"
                            runat="server" />
                        <asp:DropDownList ID="cbxCustomer" runat="server" DataSourceID="KhachHang_LINQ" DataTextField="UserName"
                            DataValueField="ID" OnDataBound="cbbLSP_DataBound" OnSelectedIndexChanged="cbbLSP_SelectedIndexChanged" />
                        <asp:LinqDataSource ID="KhachHang_LINQ" runat="server" ContextTypeName="DataAccess_Layer.DataClasses_RetailerDataContext"
                            EntityTypeName="" Select="new (ID, UserName)" TableName="Customers">
                        </asp:LinqDataSource>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="RetailCenterID" HeaderText="RetailCenterID" SortExpression="RetailCenterID"
                    Visible="False" />
                <asp:BoundField DataField="OrderStateID" HeaderText="OrderStateID" SortExpression="OrderStateID"
                    Visible="False" />
                <asp:TemplateField HeaderText="Trạng Thái">
                    <ItemTemplate>
                        <asp:Label ID="customerID" runat="Server" Text='<%# Eval("TenTT") %>' />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:Label ID="lblOrderState_ForEdit" Text='<%# Bind("OrderStateID") %>' Visible="false"
                            runat="server" />
                        <asp:DropDownList ID="cbxTrangThai" runat="server" DataSourceID="TrangThai_LINQ"
                            DataTextField="Name" DataValueField="ID" OnDataBound="cbbTT_DataBound" OnSelectedIndexChanged="cbbTT_SelectedIndexChanged" />
                        <asp:LinqDataSource ID="TrangThai_LINQ" runat="server" ContextTypeName="DataAccess_Layer.DataClasses_RetailerDataContext"
                            EntityTypeName="" Select="new (ID, Name)" TableName="OrderStates">
                        </asp:LinqDataSource>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="CreatedDate" HeaderText="NgayDatHang" SortExpression="NgayDatHang" Visible="false" />
                <asp:TemplateField HeaderText="Ngày Đặt Hàng">
                    <ItemTemplate>
                        <asp:Label ID="CreatedDateLABEL" runat="Server" Text='<%# Eval("CreatedDate", "{0:d}") %>' />
                    </ItemTemplate>
                    <InsertItemTemplate>
                        <asp:Calendar ID="CreatedDateInsertCALENDAR" runat="Server" SelectedDate='<%# Bind("CreatedDate") %>' />
                    </InsertItemTemplate>
                    <EditItemTemplate>
                        <asp:Calendar ID="CreatedDateUpdateCALENDAR" runat="Server" VisibleDate='<%# Eval("CreatedDate") %>'
                            SelectedDate='<%# Bind("CreatedDate") %>' />
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="NgayDangKyGH" HeaderText="NgayDangKyGH" SortExpression="NgayDangKyGH"
                    Visible="False" />               
                <asp:BoundField DataField="NgayVanChuyen" HeaderText="NgayVanChuyen" SortExpression="NgayVanChuyen"
                    Visible="False" />
                <asp:BoundField DataField="MuiGio" HeaderText="MuiGio" SortExpression="MuiGio" Visible="False" />
                <asp:CheckBoxField DataField="DaXoa" HeaderText="DaXoa" SortExpression="DaXoa" />
                <asp:BoundField DataField="MaNhaVanChuyen" HeaderText="MaNhaVanChuyen" SortExpression="MaNhaVanChuyen"
                    Visible="False" />
                <asp:TemplateField HeaderText="Nhà Vận Chuyển">
                    <ItemTemplate>
                        <asp:Label ID="moverID" runat="Server" Text='<%# Eval("TenNVC") %>' />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:Label ID="lblNhaVC" Text='<%# Bind("MaNhaVanChuyen") %>' Visible="false" runat="server" />
                        <asp:DropDownList ID="cbxNVC" runat="server" DataSourceID="NVC_LINQ" DataTextField="Ten"
                            DataValueField="ID" OnDataBound="cbbNVC_DataBound" OnSelectedIndexChanged="cbbNVC_SelectedIndexChanged" />
                        <asp:LinqDataSource ID="NVC_LINQ" runat="server" ContextTypeName="DataAccess_Layer.DataClasses_RetailerDataContext"
                            EntityTypeName="" Select="new (ID, Ten)" TableName="NhaVanChuyens">
                        </asp:LinqDataSource>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="DiaChiGH" HeaderText="DiaChiGH" SortExpression="DiaChiGH" />
                <asp:BoundField DataField="Thue" HeaderText="Thue" SortExpression="Thue" Visible="False" />
                <asp:BoundField DataField="TongTien" HeaderText="TongTien" SortExpression="TongTien" />
                <asp:CommandField ShowInsertButton="True" ShowEditButton="True" 
                    EditText="Cập Nhật" InsertText="Thêm" NewText="Thêm" UpdateText="Cập Nhật" />
            </Fields>            
            <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
            <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
        </asp:DetailsView>
        <asp:LinqDataSource ID="LQDSHoaDon_AM" runat="server" ContextTypeName="DataAccess_Layer.DataClasses_RetailerDataContext"
            EnableDelete="True" EnableInsert="True" EnableUpdate="True" EntityTypeName=""
            TableName="Orders" OnSelecting="LQDSNCC_GiangHang_Selecting" 
            OnUpdating="LQDSNCC_GiangHang_Updating" oninserted="LQDSHoaDon_AM_Inserted">
        </asp:LinqDataSource>
        <asp:Label runat="server" Text="Label" ID="lblThongBaoDTView" ForeColor="White" Visible="false"/>
    </fieldset>
</asp:Content>
